package packethandler;

import game.ChatRoller;
import io.ClientSession;
import io.Packet;
import player.Player;
import protocol.OpCode;
import protomsg.Chat.ChatMsg;

public class ChatRollerHandler extends PhotonHandlerBase {
	protected int[] opcodes = { 
			OpCode.SendTVMessage,
			OpCode.SendMessage,
			OpCode.SendGMTV,

	};

	public ChatRollerHandler() {
		HandlerDispatchManager.register(HandlerDispatch.PLAYER, opcodes, this);
	}
	@Override
	protected void OnOperationResponse(Object obj,
			ClientSession session) {

		Packet packet = (Packet)obj;
		byte[] bytes = packet.getData().array();

		switch (packet.getOpCode()) {
		case OpCode.SendTVMessage:

			try{

				ChatMsg tvMsg = ChatMsg.parseFrom(bytes);
				ChatRoller.SendTVMessage(tvMsg,(Player)session.getClient());
			}
			catch(Exception e){

			}


			break;

		case OpCode.SendMessage:

			try{

				ChatMsg chatMsg = ChatMsg.parseFrom(bytes);
				ChatRoller.OnRevSendMessage(chatMsg,(Player)session.getClient());
			}
			catch(Exception e){

			}

			break;



		}


	}

}
